package com.ruoyi.project.jiaqin.downmeasure.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.jiaqin.downmeasure.domain.DownMeasure;
import com.ruoyi.project.jiaqin.downmeasure.service.IDownMeasureService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 羽绒含绒量Controller
 * 
 * @author admin
 * @date 2021-01-29
 */
@Controller
@RequestMapping("/jiaqin/downmeasure")
public class DownMeasureController extends BaseController
{
    private String prefix = "jiaqin/downmeasure";

    @Autowired
    private IDownMeasureService downMeasureService;

    @RequiresPermissions("jiaqin:downmeasure:view")
    @GetMapping()
    public String downmeasure()
    {
        return prefix + "/downmeasure";
    }

    /**
     * 查询羽绒含绒量列表
     */
    @RequiresPermissions("jiaqin:downmeasure:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(DownMeasure downMeasure)
    {
        startPage();
        List<DownMeasure> list = downMeasureService.selectDownMeasureList(downMeasure);
        return getDataTable(list);
    }

    /**
     * 导出羽绒含绒量列表
     */
    @RequiresPermissions("jiaqin:downmeasure:export")
    @Log(title = "羽绒含绒量", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(DownMeasure downMeasure)
    {
        List<DownMeasure> list = downMeasureService.selectDownMeasureList(downMeasure);
        ExcelUtil<DownMeasure> util = new ExcelUtil<DownMeasure>(DownMeasure.class);
        return util.exportExcel(list, "downmeasure");
    }

    /**
     * 新增羽绒含绒量
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存羽绒含绒量
     */
    @RequiresPermissions("jiaqin:downmeasure:add")
    @Log(title = "羽绒含绒量", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(DownMeasure downMeasure)
    {
        return toAjax(downMeasureService.insertDownMeasure(downMeasure));
    }

    /**
     * 修改羽绒含绒量
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        DownMeasure downMeasure = downMeasureService.selectDownMeasureById(id);
        mmap.put("downMeasure", downMeasure);
        return prefix + "/edit";
    }

    /**
     * 修改保存羽绒含绒量
     */
    @RequiresPermissions("jiaqin:downmeasure:edit")
    @Log(title = "羽绒含绒量", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(DownMeasure downMeasure)
    {
        return toAjax(downMeasureService.updateDownMeasure(downMeasure));
    }

    /**
     * 删除羽绒含绒量
     */
    @RequiresPermissions("jiaqin:downmeasure:remove")
    @Log(title = "羽绒含绒量", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(downMeasureService.deleteDownMeasureByIds(ids));
    }
}
